package com.project.service.impl;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.bean.ProductBean;
import com.project.mapper.IProductMapper;
import com.project.service.IProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class ProductServiceImpl implements IProductService {
    @Autowired
    private IProductMapper mapper;
    @Override
    public ProductBean findById(int id) {
        return mapper.findById(id);
    }

    @Override
    public PageInfo<ProductBean> findByItem(int pageNO, String name, String type, Integer startNum, Integer endNum) {
        PageHelper.startPage(pageNO, PAGESIZE);
        PageInfo<ProductBean> pageInfo =  PageInfo.of(mapper.findByItem(name, type, startNum, endNum));
        return pageInfo;
    }

    @Override
    public void updatePrice(int productId, int price) {
        mapper.updatePrice(productId, price);
    }




}
